home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-04 / wtjmarch.zip / DEBUGWIN.ZIP / DEBUGWIN.PAS next >
Pascal/Delphi Source File  |  1992-02-21  |  2KB  |  60 lines

  1. LISTING 1: DEBUGWIN.PAS
  2. This program creates a window to hold messages from the program being debugged.
  3.  
  4. {$S-,R-}
  5.  
  6. program DebugWin;
  7.  
  8. uses
  9.   Strings, WinTypes, WinProcs, WinCrt;
  10.  
  11. const
  12.   dwTitle        = 'Debug Window';
  13.   wmsDebugString = 'wm_DebugString';
  14.  
  15. var
  16.   wm_DebugString : Word;      {message codes}
  17.   CrtWindow      : hWnd;      {WinCrt's window handle}
  18.   CrtWinProc     : TFarProc;  {WinCrt's window proc}
  19.   dwWinProc      : TFarProc;  {our window proc}
  20.  
  21.   function OurWinProc(HW : hWnd; Msg, wParam : Word;
  22.     lParam : Longint) : Longint; export;
  23.     {-Our specialized window procedure. lParam is a
  24.       pointer to a string of characters. wParam is the
  25.       number of characters in the string}
  26.   begin
  27.     if Msg = wm_DebugString then begin
  28.       {process special message}
  29.       WriteBuf(PChar(lParam), wParam);
  30.       OurWinProc := 0;
  31.     end
  32.     else
  33.       {pass message to the regular window procedure}
  34.       OurWinProc := CallWindowProc(CrtWinProc, HW, Msg, wParam, lParam);
  35.   end;
  36.  
  37. begin
  38.   {check to see if we're already loaded}
  39.   if hPrevInst <> 0 then begin
  40.     {we're already loaded--find our window}
  41.     CrtWindow := FindWindow('TPWinCrt', dwTitle);
  42.     if (CrtWindow <> 0) and IsIconic(CrtWindow) then
  43.       ShowWindow(CrtWindow, sw_ShowNormal);
  44.     Halt;
  45.   end;
  46.   ScreenSize.X := 80;
  47.   ScreenSize.Y := 65520 div 80;
  48.   WindowSize.X := GetSystemMetrics(sm_CXScreen);
  49.   WindowSize.Y := 100;
  50.   WindowOrg.X := 0;
  51.   WindowOrg.Y := 0;
  52.   StrCopy(WindowTitle, dwTitle);
  53.   InactiveTitle := dwTitle;
  54.   InitWinCrt;
  55.   CrtWindow := FindWindow('TPWinCrt', dwTitle);
  56.   dwWinProc := MakeProcInstance(@OurWinProc, hInstance);
  57.   CrtWinProc := TFarProc(SetWindowLong(CrtWindow, gwl_WndProc, LongInt(dwWinProc)) );
  58.   wm_DebugString := RegisterWindowMessage(wmsDebugString);
  59. end.
  60.